package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Footprints;
import com.ruoyi.system.service.IFootprintsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 足迹Controller
 * 
 * @author ruoyi
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/system/footprints")
public class FootprintsController extends BaseController
{
    @Autowired
    private IFootprintsService footprintsService;

    /**
     * 查询足迹列表
     */
    @PreAuthorize("@ss.hasPermi('system:footprints:list')")
    @GetMapping("/list")
    public TableDataInfo list(Footprints footprints)
    {
        startPage();
        List<Footprints> list = footprintsService.selectFootprintsList(footprints);
        return getDataTable(list);
    }

    /**
     * 导出足迹列表
     */
    @PreAuthorize("@ss.hasPermi('system:footprints:export')")
    @Log(title = "足迹", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Footprints footprints)
    {
        List<Footprints> list = footprintsService.selectFootprintsList(footprints);
        ExcelUtil<Footprints> util = new ExcelUtil<Footprints>(Footprints.class);
        util.exportExcel(response, list, "足迹数据");
    }

    /**
     * 获取足迹详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:footprints:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(footprintsService.selectFootprintsById(id));
    }

    /**
     * 新增足迹
     */
    @PreAuthorize("@ss.hasPermi('system:footprints:add')")
    @Log(title = "足迹", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Footprints footprints)
    {
        return toAjax(footprintsService.insertFootprints(footprints));
    }

    /**
     * 修改足迹
     */
    @PreAuthorize("@ss.hasPermi('system:footprints:edit')")
    @Log(title = "足迹", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Footprints footprints)
    {
        return toAjax(footprintsService.updateFootprints(footprints));
    }

    /**
     * 删除足迹
     */
    @PreAuthorize("@ss.hasPermi('system:footprints:remove')")
    @Log(title = "足迹", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(footprintsService.deleteFootprintsByIds(ids));
    }
}
